<template>
	<view>
		<navbar title="店铺认证" :back="true" bgColor="#FFF" />
		<view class="p-20">
			<view v-if="statue==0"
				style="height: 110rpx;background: #FFE09F;border-radius: 16rpx 16rpx 16rpx 16rpx;color: #AC760F;padding: 20rpx;">
				<view class="u-flex u-row-left">
					<image src="../../static/icon/rz.png" style="width: 36rpx;height: 36rpx;" />
					<text style="font-size: 32rpx;margin-left: 10rpx;">店铺认证</text>
				</view>
				<view style="font-size: 24rpx;margin-top: 30rpx;">店铺认证是在通过核实店铺ID和名称，证明店铺的真实性</view>
			</view>
			<view v-else-if="statue==1" class="u-flex u-row-center u-flex-wrap"
				style="background-color: #FFFFFF;border-radius: 16rpx;padding: 40rpx;">
				<image src="../../static/icon/s3.png" style="width: 104rpx;height: 104rpx;" />
				<view style="width: 100%;text-align: center;font-size: 28rpx;color: #333333;line-height: 60rpx;">信息审核中
				</view>
				<view style="width: 100%;text-align: center;font-size: 24rpx;color: #999999;">请耐心等待，预计1~3个工作日完成审核</view>
			</view>
			<view v-else-if="statue==2" class="u-flex u-row-center u-flex-wrap"
				style="background-color: #FFFFFF;border-radius: 16rpx;padding: 40rpx;">
				<image src="../../static/icon/s1.png" style="width: 104rpx;height: 104rpx;" />
				<view style="width: 100%;text-align: center;font-size: 28rpx;color: #333333;line-height: 60rpx;">认证成功
				</view>
				<view style="width: 100%;text-align: center;font-size: 24rpx;color: #999999;">信息无误，店铺认证已完成</view>
			</view>


			<view v-else-if="statue==3" class="u-flex u-row-center u-flex-wrap"
				style="background-color: #FFFFFF;border-radius: 16rpx;padding: 40rpx;">
				<image src="../../static/icon/s2.png" style="width: 104rpx;height: 104rpx;" />
				<view style="width: 100%;text-align: center;font-size: 28rpx;color: #333333;line-height: 60rpx;">认证失败
				</view>
				<view style="width: 100%;text-align: center;font-size: 24rpx;color: #999999;">{{failMsg}}</view>
			</view>

			<view style="background-color: #FFFFFF;border-radius: 16rpx;" class="p-20 m-t-20">
				<view style="color: #333333;font-size: 32rpx;font-weight: bold;line-height: 80rpx;">店铺信息</view>
				<u-form :model="params" :rules="rules" ref="form" errorType="toast" label-width="200rpx">
					<!-- <u-form-item prop="shopName" class="in" borderBottom label="店铺名称">
						<u--input v-model="params.shopName" border="none" placeholder="请输入您的店铺名称"></u--input>
					</u-form-item> -->

					<u-form-item prop="shopId" class="in" label="店铺ID">
						<u--input v-model="params.shopId" border="none" placeholder="请输入您的店铺ID"
							:readonly="statue!=0"></u--input>
					</u-form-item>
				</u-form>
			</view>

			<view style="background-color: #FFFFFF;border-radius: 16rpx;" class="p-20 m-t-20">
				<view>
					<view style="color: #333333;font-size: 32rpx;font-weight: bold;">证明材料</view>
					<view style="color: #999999;font-size: 24rpx">请上传材料证明此Id是您的店铺（百应后台登录状态截图）</view>
				</view>
				<uploadImage :multiple="true" :maxCount="3" style="margin-top: 30rpx;" @success="success" ref="up"
					:disabled="statue!=0" />
				<view style="margin:  30rpx 0;">
					<u-line height="100%" />
				</view>

				<view>
					<view style="color: #333333;font-size: 32rpx;font-weight: bold;line-height: 80rpx;">认证后您可以：</view>
					<view style="color: #333333;font-size: 24rpx;line-height: 48rpx;">
						<view>1.同步店铺商品数据以及查看运营数据</view>
						<view>2.查看BD出单情况，寄养审核管理，商品管理等</view>
					</view>
				</view>

			</view>
			<view class="btn" @tap="auth()" v-if="statue==0">
				提交信息
			</view>

			<view class="btn" @tap="statue=0" v-if="statue==3">
				重新认证
			</view>
		</view>

	</view>
</template>

<script>
	import {
		shopAuth,
		getShopAuthInfo
	} from '@/api/shop.js'

	import navbar from '@/components/baseNavbar.vue'
	import uploadImage from '@/components/uploadImage.vue'
	import {
		getConfig,
	} from "@/api/public.js"
	export default {
		components: {
			navbar,
			uploadImage
		},
		data() {
			return {
				failMsg: '',
				statue: 0,
				params: {
					image: []
				},
				rules: {}
			};
		},
		onLoad() {

		},
		onShow() {
			this.getInfo((value) => {
				if (value) {
					this.statue = value.statue == 0 ? 1 : value.statue == 1 ? 2 : 3
					this.params = {
						image: value.image,
						shopName: value.shopName,
						shopId: value.shopId
					}
					this.failMsg = value.failMsg
					value.image.forEach(item => {
						this.$refs['up'].add(item)
					})

				}
			})
		},
		computed: {},
		methods: {
			getInfo(callBack) {
				getShopAuthInfo().then(res => {
					callBack(res.data)
				})
			},
			auth() {
				shopAuth(this.params).then(res => {
					uni.showToast({
						icon: "none",
						title: "提交认证成功,请等待审核。"
					})
					this.statue = 1
				})
			},
			goHome() {
				uni.switchTab({
					url: "/pages/index/index"
				})
			},
			success(img) {
				this.params.image = img
			}
		},

		onReady() {

		}
	};
</script>
<style>
	page {
		background-color: #F5F5F5;
	}
</style>
<style lang="scss" scoped>
	.btn {
		width: 702rpx;
		line-height: 88rpx;
		background: #007DF7;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		font-size: 28rpx;
		color: #FFFFFF;
		text-align: center;
		margin-top: 60rpx;
	}
</style>